package com.relatev.minecraft.TRMobAPI;

import java.util.ArrayList;
import org.bukkit.Bukkit;

public class RunnableWorker implements Runnable {

    private ArrayList<Runnable> RunnableList = new ArrayList<>();

    public RunnableWorker() {
        Bukkit.getScheduler().runTaskTimer(TRMobAPI.getAPI(), this, 1, 1);
    }

    @Override
    public void run() {
        for(Runnable run:RunnableList){
            run.run();
        }
        RunnableList.clear();
    }

    public void offerRunnable(Runnable run) {
        RunnableList.add(run);
    }
    
    public void clearRunnables(){
        RunnableList.clear();
    }
}
